<?php
/**
 * $files (array of File) files to show
 * $fileDir (ej. "tmp")
 */
$fileDir = SimpleUploadWidget::$fileDir;
$deleteUploadAction = UploadWidget::PREFIX.SimpleUploadWidget::DELETE_ACTION;
?>
<div style="float:left;">
    <?php foreach($files as $file): ?>
    <div>
        <a href="<?= UploadUtils::getUrl($fileDir)."/".$file->filename; ?>"
           title="<?=$file->filename?> (<?=round($file->filesize/1024, 2)?> Kb)">
            <?php if (UploadUtils::isImageFileMime($file->filemime)): ?>
                <img height="50px" alt="<?=$file->filename?>"
                     src="<?= UploadUtils::getUrl($fileDir)."/".$file->filename; ?>"/>
            <?php else: ?>
                <?=$file->filename?>
            <?php endif; ?>
        </a>
        <?php
        print CHtml::ajaxLink(
            "Delete",
            array($deleteUploadAction, 'fid'=>$file->fid),
            array(
                'dataType'=>'json',
                'success'=>'function(json) { if (json.result==0) location.reload(); }',
            )
        );
        ?>
    </div>
    <?php endforeach; ?>
</div>
<div style="clear:both;"/>